package demo.practice.leetcode_eveyday;

import java.util.ArrayList;
import java.util.List;

public class P119 {

    public List<Integer> getRow(int rowIndex) {
        if (rowIndex<0)
            return new ArrayList<>();
        if(rowIndex==0){
            List<Integer> li= new ArrayList<>();
            li.add(1);
            return li;
        }else if(rowIndex==1){
            List<Integer> row = getRow(rowIndex-1);
            row.add(1);
            return row;
        }else{
            //1
            //1 1
            //1 2 1
            //1 3 3 1
            List<Integer> all = getRow(rowIndex - 1);
            all.add(1);
            for(int i=all.size()-2;i>0;i--){
                all.set(i,all.get(i-1)+all.get(i));
            }

            return all;
        }
    }

}
